package com.lb.jwitter.action;


import java.util.Collection;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.ApplicationContext;
import java.util.Map; 
import org.springframework.test.context.ContextConfiguration; 
import com.lb.jwitter.service.TblQuyenChiTietService; 
import com.lb.jwitter.service.TblTaiKhoan; 
import com.opensymphony.xwork2.ActionContext; 
import com.lb.jwitter.util.ApplicationContextProvider; 
import org.springframework.context.support.ClassPathXmlApplicationContext;
import com.opensymphony.xwork2.Action; 
import com.lb.jwitter.service.TblQLDTTXAHocVien;
import com.lb.jwitter.service.TblQLDTTXAHocVienService;
import com.lb.jwitter.service.TblQLDTTXALop;
import com.lb.jwitter.service.TblQLDTTXALopService;

import com.lb.jwitter.service.TblQLDTTXADMNganh;
import com.lb.jwitter.service.TblQLDTTXADMNganhService;

import com.lb.jwitter.service.TblQLDTTXADMKhoa;
import com.lb.jwitter.service.TblQLDTTXADMKhoaService;

import com.lb.jwitter.service.TblQLDTTXADMKhoaHoc;
import com.lb.jwitter.service.TblQLDTTXADMKhoaHocService;

import com.lb.jwitter.service.TblQLDTTXADMChiNhanh;
import com.lb.jwitter.service.TblQLDTTXADMChiNhanhService;

import com.lb.jwitter.service.TblQLDTTXAHoSoXetTuyen;
import com.lb.jwitter.service.TblQLDTTXAHoSoXetTuyenService;

import com.lb.jwitter.service.TblQLDTTXADMTrangThaiHocVien;
import com.lb.jwitter.service.TblQLDTTXADMTrangThaiHocVienService;

 /** 
 * @author QUOCVIET  
 * 
 */ 


@ContextConfiguration(locations="classpath:beans.xml") 
public class TblQLDTTXAHocVienAddFormAction{
    private int id; 
    public void setId(int id) {
       this.id = id;
 }

    public int getId() {
       return id;
 }

    private Collection<TblQLDTTXALop> tblQLDTTXALops; 
    public Collection<TblQLDTTXALop>  getTblQLDTTXALops(){ 
              return tblQLDTTXALops; 
     } 

    private TblQLDTTXALopService tblQLDTTXALopService; 

    private Collection<TblQLDTTXADMNganh> tblQLDTTXADMNganhs; 
    public Collection<TblQLDTTXADMNganh>  getTblQLDTTXADMNganhs(){ 
              return tblQLDTTXADMNganhs; 
     } 

    private TblQLDTTXADMNganhService tblQLDTTXADMNganhService; 

    private Collection<TblQLDTTXADMKhoa> tblQLDTTXADMKhoas; 
    public Collection<TblQLDTTXADMKhoa>  getTblQLDTTXADMKhoas(){ 
              return tblQLDTTXADMKhoas; 
     } 

    private TblQLDTTXADMKhoaService tblQLDTTXADMKhoaService; 

    private Collection<TblQLDTTXADMKhoaHoc> tblQLDTTXADMKhoaHocs; 
    public Collection<TblQLDTTXADMKhoaHoc>  getTblQLDTTXADMKhoaHocs(){ 
              return tblQLDTTXADMKhoaHocs; 
     } 

    private TblQLDTTXADMKhoaHocService tblQLDTTXADMKhoaHocService; 

    private Collection<TblQLDTTXADMChiNhanh> tblQLDTTXADMChiNhanhs; 
    public Collection<TblQLDTTXADMChiNhanh>  getTblQLDTTXADMChiNhanhs(){ 
              return tblQLDTTXADMChiNhanhs; 
     } 

    private TblQLDTTXADMChiNhanhService tblQLDTTXADMChiNhanhService; 

    private Collection<TblQLDTTXAHoSoXetTuyen> tblQLDTTXAHoSoXetTuyens; 
    public Collection<TblQLDTTXAHoSoXetTuyen>  getTblQLDTTXAHoSoXetTuyens(){ 
              return tblQLDTTXAHoSoXetTuyens; 
     } 

    private TblQLDTTXAHoSoXetTuyenService tblQLDTTXAHoSoXetTuyenService; 

    private Collection<TblQLDTTXADMTrangThaiHocVien> tblQLDTTXADMTrangThaiHocViens; 
    public Collection<TblQLDTTXADMTrangThaiHocVien>  getTblQLDTTXADMTrangThaiHocViens(){ 
              return tblQLDTTXADMTrangThaiHocViens; 
     } 

    private TblQLDTTXADMTrangThaiHocVienService tblQLDTTXADMTrangThaiHocVienService; 

  private TblTaiKhoan taiKhoanDangNhap; 
 public TblTaiKhoan getTaiKhoanDangNhap() { 
     return taiKhoanDangNhap; 
 } 
 public void setTaiKhoanDangNhap(TblTaiKhoan taiKhoanDangNhap) { 
     this.taiKhoanDangNhap = taiKhoanDangNhap; 
 } 
 private TblQuyenChiTietService tblQuyenChiTietService;
	 @Autowired // Injected by Spring 
     ApplicationContextProvider contextProvider; 
    public String execute() throws Exception 
   { 
    try{ 
     Map session = ActionContext.getContext().getSession();
     taiKhoanDangNhap =  (TblTaiKhoan) session.get("taiKhoan");
     if( taiKhoanDangNhap == null) return "noprivilege";
    ApplicationContext context = ApplicationContextProvider.getApplicationContext(); 
    tblQuyenChiTietService = (TblQuyenChiTietService) context.getBean("tbl_Quyen_ChiTietClient"); 
    if(!tblQuyenChiTietService.checkRight(taiKhoanDangNhap.getMaNhomQuyen().getId(), "tbl_QLDTTXA_HocVien", "them")){ 
        return "noprivilege"; 
    }        tblQLDTTXALopService = (TblQLDTTXALopService) context.getBean("tbl_QLDTTXA_LopClient"); 

        tblQLDTTXADMNganhService = (TblQLDTTXADMNganhService) context.getBean("tbl_QLDTTXA_DM_NganhClient"); 

        tblQLDTTXADMKhoaService = (TblQLDTTXADMKhoaService) context.getBean("tbl_QLDTTXA_DM_KhoaClient"); 

        tblQLDTTXADMKhoaHocService = (TblQLDTTXADMKhoaHocService) context.getBean("tbl_QLDTTXA_DM_KhoaHocClient"); 

        tblQLDTTXADMChiNhanhService = (TblQLDTTXADMChiNhanhService) context.getBean("tbl_QLDTTXA_DM_ChiNhanhClient"); 

        tblQLDTTXAHoSoXetTuyenService = (TblQLDTTXAHoSoXetTuyenService) context.getBean("tbl_QLDTTXA_HoSoXetTuyenClient"); 

        tblQLDTTXADMTrangThaiHocVienService = (TblQLDTTXADMTrangThaiHocVienService) context.getBean("tbl_QLDTTXA_DM_TrangThaiHocVienClient"); 

        tblQLDTTXALops = tblQLDTTXALopService.findAlltblQLDTTXALop(0, 0);

        tblQLDTTXADMNganhs = tblQLDTTXADMNganhService.findAlltblQLDTTXADMNganh(0, 0);

        tblQLDTTXADMKhoas = tblQLDTTXADMKhoaService.findAlltblQLDTTXADMKhoa(0, 0);

        tblQLDTTXADMKhoaHocs = tblQLDTTXADMKhoaHocService.findAlltblQLDTTXADMKhoaHoc(0, 0);

        tblQLDTTXADMChiNhanhs = tblQLDTTXADMChiNhanhService.findAlltblQLDTTXADMChiNhanh(0, 0);

//        tblQLDTTXAHoSoXetTuyens = tblQLDTTXAHoSoXetTuyenService.findAlltblQLDTTXAHoSoXetTuyen(0, 0);

        tblQLDTTXADMTrangThaiHocViens = tblQLDTTXADMTrangThaiHocVienService.findAlltblQLDTTXADMTrangThaiHocVien(0, 0);

        return Action.SUCCESS; 
      } 
      catch(Exception e){ 
      System.out.println("Loi AddForm tbl_QLDTTXA_HocVien Action"); 
     e.printStackTrace(); 
    return Action.ERROR; 
 } 
 } 
 } 
 
